import java.util.Scanner;

public class Text3 {
    //DNA序列  笔试强训  day16 第三题
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        //双指针 滑动窗口  也可以暴力遍历
        String str = in.next();
        int len = in.nextInt();

        //定义两个指针
        int left= 0;
        int right= 0;
        int n = str.length();
        int count = 0;
        int max = 0;
        int ret = 0;  //记录起始位置
        while(right < n) {
            //进窗口
            if(str.charAt(right) == 'C' || str.charAt(right) == 'G') {
                count++;
            }
            //出窗口
            if(right - left +1 > len) {
                if(str.charAt(left) == 'C' || str.charAt(left) == 'G') {
                    count--;
                }
                left++;
            }

            //更新结果
            if(right-left+1 == len) {
                if(count > max) {
                    max = count;
                    ret = left;
                }
            }
            right++;  //找玩一次right++
        }
        //输出
        System.out.println(str.substring(ret,ret+len));
    }
}
